home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / RAND / UNSPLIT / BM214SRC.ZIP / 68030 / IO.S < prev    next >
Encoding:
Text File  |  1996-06-29  |  40.1 KB  |  1,519 lines

  1. *=======================================================*
  2. *    IO routines: latest update 25/03/96        *
  3. *=======================================================*
  4. *    Handle all WAD related processes        *
  5. *=======================================================*
  6.  
  7.     include        include\wad_tab.s
  8.     
  9. *-------------------------------------------------------*
  10. parse_cli:
  11. *-------------------------------------------------------*
  12.     moveq        #0,d0
  13. *-------------------------------------------------------*
  14.     ifnd        test
  15. *-------------------------------------------------------*
  16.     move.l        cli,a4
  17.     move.b        (a4)+,d0
  18.     beq        safe_quit
  19. *-------------------------------------------------------*
  20.     elseif
  21. *-------------------------------------------------------*
  22.     lea        default_path,a4
  23.     move.b        #255,d0
  24. *-------------------------------------------------------*
  25.     endc
  26. *-------------------------------------------------------*    
  27.     lea        cli_space,a5
  28.     clr.b        (a4,d0.l)
  29. .all:    move.b        (a4)+,(a5)+
  30.     bne.s        .all
  31. *-------------------------------------------------------*
  32.     lea        levelmarker,a0
  33.     move.l        #-1,(a0)
  34. *-------------------------------------------------------*
  35. *    Parse new CLI                    *
  36. *-------------------------------------------------------*
  37.     bsr        parse_new_cli
  38. *-------------------------------------------------------*
  39.     tst.b        iwad_path
  40.     bne.s        .not_old_cli
  41. *-------------------------------------------------------*
  42. *    Parse old CLI if new format not detected    *
  43. *-------------------------------------------------------*
  44.     bsr        parse_old_cli
  45. *-------------------------------------------------------*
  46. .not_old_cli:
  47. *-------------------------------------------------------*
  48.     rts
  49.  
  50. *-------------------------------------------------------*
  51. parse_new_cli:
  52. *-------------------------------------------------------*
  53.     lea        cli_space,a5
  54. *-------------------------------------------------------*
  55. *    Check for last character            *
  56. *-------------------------------------------------------*
  57. .nwad:    move.b        (a5)+,d1
  58.     beq        .adon
  59.     fixcase        d1
  60. *-------------------------------------------------------*
  61. *    Check for option                *
  62. *-------------------------------------------------------*
  63.     cmp.b        #'-',d1
  64.     bne        .odon
  65. *-------------------------------------------------------*
  66. *    Check for new IWAD path                * 
  67. *-------------------------------------------------------*
  68.     lea        ascii_iwad_switch,a0
  69.     bsr        check_switch
  70.     tst.l        d0
  71.     bmi.s        .niwad
  72.     lea        iwad_path,a1
  73.     move.w        #255,d7
  74.     bsr        load_parameter
  75.     bra.s        .odon
  76. *-------------------------------------------------------*
  77. *    Check for new PWAD path                * 
  78. *-------------------------------------------------------*
  79. .niwad:    lea        ascii_pwad_switch,a0
  80.     bsr        check_switch
  81.     tst.l        d0
  82.     bmi.s        .npwad
  83.     lea        pwad_path,a1
  84.     move.w        #255,d7
  85.     bsr        load_parameter
  86.     bra.s        .odon
  87. *-------------------------------------------------------*
  88. *    Check for 'warp' level select            *
  89. *-------------------------------------------------------*
  90. .npwad:    lea        ascii_warp_switch,a0
  91.     bsr        check_switch
  92.     tst.l        d0
  93.     bmi.s        .odon
  94.     lea        levelmarker,a1
  95.     moveq        #8,d7
  96.     bsr        load_parameter
  97. *-------------------------------------------------------*
  98. *    Continue until CLI exhausted            *
  99. *-------------------------------------------------------*
  100. .odon:    bra        .nwad
  101. *-------------------------------------------------------*
  102. .adon:    rts
  103.  
  104. *-------------------------------------------------------*
  105. load_parameter:
  106. *-------------------------------------------------------*
  107.     move.l        a5,a2
  108.     bsr        skip_padding
  109. *-------------------------------------------------------*
  110. .next:    move.b        (a2)+,d1
  111.     beq.s        .done
  112. *-------------------------------------------------------*
  113.     fixcase        d1
  114.     cmp.b        #'.',d1
  115.     blo.s        .done
  116.     cmp.b        #'z',d1
  117.     bhi.s        .done
  118.     move.b        d1,(a1)+
  119.     bra.s        .next
  120. *-------------------------------------------------------*
  121. .done:    clr.b        (a1)
  122.     rts
  123.     
  124. *-------------------------------------------------------*
  125. skip_padding:
  126. *-------------------------------------------------------*
  127. .next:    move.b        (a2)+,d1
  128.     beq.s        .err
  129.     fixcase        d1
  130.     cmp.b        #'.',d1
  131.     blo.s        .next
  132.     cmp.b        #'z',d1
  133.     bhi.s        .next
  134. .err:    subq.l        #1,a2
  135.     rts
  136.  
  137. *-------------------------------------------------------*
  138. check_switch:
  139. *-------------------------------------------------------*
  140.     move.l        a5,a4
  141. *-------------------------------------------------------*
  142. .next:    move.b        (a0),d0
  143.     move.b        (a4),d4
  144.     fixcase        d0
  145.     fixcase        d4
  146.     cmp.b        #'.',d0
  147.     blo.s        .done
  148.     cmp.b        #'z',d0
  149.     bhi.s        .done
  150.     cmp.b        #'.',d4
  151.     blo.s        .done
  152.     cmp.b        #'z',d4
  153.     bhi.s        .done
  154. *-------------------------------------------------------*
  155.     cmp.b        d0,d4
  156.     bne.s        .err
  157. *-------------------------------------------------------*
  158.     addq.l        #1,a0
  159.     addq.l        #1,a4
  160.     bra.s        .next
  161. *-------------------------------------------------------*
  162. .err:    moveq        #-1,d0
  163.     bra.s        .exit
  164. *-------------------------------------------------------*
  165. .done:    move.l        a4,a5
  166.     moveq        #0,d0
  167. .exit:    rts
  168.     
  169. *-------------------------------------------------------*
  170. parse_old_cli:
  171. *-------------------------------------------------------*
  172.     lea        cli_space,a5
  173. *-------------------------------------------------------*
  174. *    Parse options                    *
  175. *-------------------------------------------------------*
  176. .load:    lea        iwad_path,a0
  177.     lea        levelmarker,a2
  178. *-------------------------------------------------------*
  179. *    Check for last character            *
  180. *-------------------------------------------------------*
  181. .nwad:    move.b        (a5)+,d1
  182.     beq.s        .adon
  183.     fixcase        d1
  184.     cmp.b        #' ',d1
  185.     beq.s        .nlwad
  186.     move.b        d1,(a0)+
  187.     bra.s        .nwad
  188. *-------------------------------------------------------*
  189. .nlwad:    move.b        (a5)+,d1
  190.     beq.s        .done
  191.     fixcase        d1
  192.     move.b        d1,(a2)+
  193.     bra.s        .nlwad
  194. .done:    clr.b        (a2)
  195. *-------------------------------------------------------*
  196. *    Terminate IWAD path string            *
  197. *-------------------------------------------------------*
  198. .adon:    clr.b        (a0)
  199.     rts
  200.  
  201. *-------------------------------------------------------*
  202. *    Read details from IWAD                *
  203. *-------------------------------------------------------*
  204. parse_iwad:
  205. *-------------------------------------------------------*
  206.     Cconws        #ascii_startup
  207.     bsr        open_wad
  208.     tst.w        d0
  209.     bmi        err_openwad
  210. .wad_check:
  211.     lea        wad_header,a5
  212.     Fread        wad_handle,#wh_len,a5
  213.     move.l        wh_sig(a5),d0
  214.     cmp.l        #'IWAD',d0
  215.     bne        err_badwad
  216. .sig_valid:
  217.     move.l        d0,wad_signature
  218.     Cconws        #ascii_format1
  219.     Cconws        #wad_signature
  220.     imov.l        wh_entries(a5),d1
  221.     move.l        d1,wad_entries
  222.     tst.l        d1
  223.     beq        err_badwad
  224.     imov.l        wh_directory(a5),wad_diroffset
  225.     Cconws        #ascii_entries
  226.     move.l        wad_entries,d0
  227.     moveq        #0,d1
  228.     bsr        output_decimal
  229.     Fseek        wad_diroffset,wad_handle,#0
  230.     bsr        wad_readall
  231.     rts    
  232.  
  233. *-------------------------------------------------------*
  234. *    Read details from PWAD                *
  235. *-------------------------------------------------------*
  236. parse_pwad:
  237. *-------------------------------------------------------*
  238.     tst.b        pwad_path
  239.     beq        .no_pwad
  240. *-------------------------------------------------------*
  241.     bsr        open_pwad
  242.     tst.w        d0
  243.     bmi        err_openwad
  244. .wad_check:
  245.     lea        pwad_header,a5
  246.     Fread        pwad_handle,#wh_len,a5
  247.     move.l        wh_sig(a5),d0
  248.     cmp.l        #'PWAD',d0
  249.     bne        err_badpwad
  250. .sig_valid:
  251.     move.l        d0,pwad_signature
  252.     Cconws        #ascii_format2
  253.     Cconws        #pwad_signature
  254.     imov.l        wh_entries(a5),d1
  255.     move.l        d1,pwad_entries
  256.     tst.l        d1
  257.     beq        err_badpwad
  258.     imov.l        wh_directory(a5),pwad_diroffset
  259.     Cconws        #ascii_entries
  260.     move.l        pwad_entries,d0
  261.     moveq        #0,d1
  262.     bsr        output_decimal
  263.     Fseek        pwad_diroffset,pwad_handle,#0
  264.     bsr        pwad_readall
  265. *-------------------------------------------------------*
  266. .no_pwad:
  267. *-------------------------------------------------------*
  268.     rts    
  269.  
  270. *-------------------------------------------------------*
  271. *    Integrate PWAD directory into main        *
  272. *-------------------------------------------------------*
  273. integrate_wads:
  274. *-------------------------------------------------------*
  275.     tst.b        pwad_path
  276.     beq        .no_pwad
  277. *-------------------------------------------------------*
  278. *    Build quick-search hastable for IWAD        *
  279. *-------------------------------------------------------*
  280.     bsr        build_directory_hash
  281.     Cconws        #ascii_integrate
  282. *-------------------------------------------------------*
  283. *    Integrate each new entry into main        *
  284. *-------------------------------------------------------*
  285.     move.l        pwad_directory,a3
  286.     move.l        pwad_entries,d7
  287.     bra        .go
  288. *-------------------------------------------------------*
  289. .all:    lea        wd_name(a3),a0    
  290.     bsr        locate_entry
  291.     tst.l        d0
  292.     beq.s        .append_entry
  293. *-------------------------------------------------------*
  294. .patch_entry:
  295. *-------------------------------------------------------*
  296. *    Patch entry over main directory            *
  297. *-------------------------------------------------------*
  298.     move.l        d0,a4
  299.     moveq        #0,d6
  300.     bra.s        .check_type
  301. *-------------------------------------------------------*
  302. .append_entry:
  303. *-------------------------------------------------------*
  304. *    Append entry to main directory            *
  305. *-------------------------------------------------------*
  306.     move.l        all_directory,a4
  307.     move.l        wad_entries,d1
  308.     mulu.l        #wd_len,d1
  309.     add.l        d1,a4
  310.     moveq        #1,d6
  311. *-------------------------------------------------------*
  312. *    Check entry size (could be a whole group)    *
  313. *-------------------------------------------------------*
  314. .check_type:
  315. *-------------------------------------------------------*
  316.     lea        wd_name(a3),a0    
  317. *-------------------------------------------------------*
  318. *    Check for Doom level marker            *
  319. *-------------------------------------------------------*
  320.     lea        ascii_mask_exmx,a1
  321.     bsr        strcmp_8_wild
  322.     tst.w        d0
  323.     bne.s        .level_group
  324. *-------------------------------------------------------*
  325. *    Check for Doom II level marker            *
  326. *-------------------------------------------------------*
  327.     lea        ascii_mask_mapxx,a1
  328.     bsr        strcmp_8_wild
  329.     tst.w        d0
  330.     bne.s        .level_group
  331. *-------------------------------------------------------*
  332. *    Entry is a singular element            *
  333. *-------------------------------------------------------*
  334. .single_entry:
  335. *-------------------------------------------------------*
  336.     move.l        a4,a2
  337.     move.l        a3,a0
  338.     moveq        #(wd_len/4)-1,d0
  339. .copy:    move.l        (a0)+,(a2)+
  340.     dbra        d0,.copy
  341. *-------------------------------------------------------*
  342. *    Mark entry as PWAD resource            *
  343. *-------------------------------------------------------*
  344.     bset        #7,wd_offset(a4)
  345. *-------------------------------------------------------*
  346. *    Advance to next entry                *
  347. *-------------------------------------------------------*
  348.     add.l        d6,all_entries
  349.     lea        wd_len(a3),a3
  350. *-------------------------------------------------------*
  351.     bra.s        .entry_done
  352. *-------------------------------------------------------*
  353. *    Entry is a group of elements            *
  354. *-------------------------------------------------------*
  355. .level_group:
  356. *-------------------------------------------------------*
  357. .element_loop:
  358. *-------------------------------------------------------*
  359.     move.l        a4,a2
  360.     move.l        a3,a0
  361.     moveq        #(wd_len/4)-1,d0
  362. .copy1:    move.l        (a0)+,(a2)+
  363.     dbra        d0,.copy1
  364. *-------------------------------------------------------*
  365. *    Mark entry as PWAD resource            *
  366. *-------------------------------------------------------*
  367.     bset        #7,wd_offset(a4)
  368. *-------------------------------------------------------*
  369. *    Advance to next entry                *
  370. *-------------------------------------------------------*
  371.     add.l        d6,all_entries
  372.     lea        wd_len(a4),a4
  373.     lea        wd_len(a3),a3
  374. *-------------------------------------------------------*
  375. *    Continue until entry not recognised        *
  376. *-------------------------------------------------------*
  377.     lea        level_fieldlist,a2
  378.     lea        wd_name(a3),a0
  379. .next:    move.l        0(a2),d0
  380.     lea        8(a2),a2
  381.     tst.l        d0
  382.     ble.s        .entry_done
  383.     move.l        d0,a1
  384.     bsr        strcmp_8
  385.     tst.w        d0
  386.     beq.s        .next
  387. *-------------------------------------------------------*
  388.     bra.s        .element_loop
  389. *-------------------------------------------------------*
  390. .entry_done:
  391. *-------------------------------------------------------*
  392. .go:    dbra        d7,.all
  393. *-------------------------------------------------------*
  394. .no_pwad:
  395. *-------------------------------------------------------*
  396.     rts
  397.  
  398. *-------------------------------------------------------*
  399. *    Create hashtable to reduce search overheads    *
  400. *-------------------------------------------------------*
  401. build_directory_hash:
  402. *-------------------------------------------------------*
  403. *    Create hashtable for all valid entries        *
  404. *-------------------------------------------------------*
  405. .cont:    bsr        empty_hash
  406.     move.l        all_directory,a0
  407.     move.l        all_entries,d7
  408.     move.l        hash_array,a2
  409.     bra.s        .go
  410. *-------------------------------------------------------*
  411. *    Generate hash index for entry            *
  412. *-------------------------------------------------------*
  413. .all:    lea        wd_name(a0),a1
  414.     bsr        hash_name
  415. *-------------------------------------------------------*
  416. *    Store reference in hash table            *
  417. *-------------------------------------------------------*
  418.     move.w        #max_hash-1,d4
  419. .find:    and.w        #max_hash-1,d1
  420.     tst.l        (a2,d1.w*4)
  421.     beq.s        .slot
  422.     addq.w        #1,d1
  423.     dbra        d4,.find
  424. .slot:    move.l        a0,(a2,d1.w*4)
  425. *-------------------------------------------------------*
  426.     lea        wd_len(a0),a0
  427. .go:    dbra        d7,.all
  428. .exit:    rts
  429.  
  430. *-------------------------------------------------------*
  431. *    Track down one entry in directory        *
  432. *-------------------------------------------------------*
  433. locate_entry:    
  434. *-------------------------------------------------------*
  435.     move.l        a0,a1
  436.     bsr        hash_name
  437.     move.l        hash_array,a2
  438.     move.w        #max_hash-1,d4
  439. .find:    and.w        #max_hash-1,d1
  440.     move.l        (a2,d1.w*4),d5
  441.     beq.s        .err
  442.     move.l        d5,a1
  443.     lea        wd_name(a1),a1
  444.     bsr        strcmp_8
  445.     tst.w        d0
  446.     beq.s        .cont
  447.     move.l        d5,d0
  448.     bra.s        .exit
  449. .cont:    addq.w        #1,d1
  450.     dbra        d4,.find
  451. .err:    moveq        #0,d0
  452. .exit:    rts
  453.  
  454. *-------------------------------------------------------*
  455. *    Read all IWAD directory entries            *
  456. *-------------------------------------------------------*
  457. wad_readall:
  458. *-------------------------------------------------------*
  459.     move.l        #max_wad_entries,d0
  460.     mulu.l        #wd_len,d0
  461.     move.l        d0,d7
  462.     Malloc        d0
  463.     tst.l        d0
  464.     ble        err_memory
  465.     move.l        d0,wad_directory
  466.     Fread        wad_handle,d7,d0
  467. .reformat_directory:
  468.     move.l        wad_directory,a0
  469.     move.l        wad_entries,d7
  470. .reformat_next:
  471.     imov.l        wd_offset(a0),wd_offset(a0)
  472.     imov.l        wd_size(a0),wd_size(a0)
  473.     lea        wd_len(a0),a0
  474.     subq.l        #1,d7
  475.     bne.s        .reformat_next
  476. *-------------------------------------------------------*
  477. *    Prepare to merge IWAD & PWAD directories    *
  478. *-------------------------------------------------------*
  479.     move.l        wad_entries,all_entries
  480.     move.l        wad_directory,all_directory
  481. *-------------------------------------------------------*
  482.     rts
  483.  
  484. *-------------------------------------------------------*
  485. *    Read all PWAD directory entries            *
  486. *-------------------------------------------------------*
  487. pwad_readall:
  488. *-------------------------------------------------------*
  489.     move.l        pwad_entries,d0
  490.     mulu.l        #wd_len,d0
  491.     move.l        d0,d7
  492.     Malloc        d0
  493.     tst.l        d0
  494.     ble        err_memory
  495.     move.l        d0,pwad_directory
  496.     Fread        pwad_handle,d7,d0
  497. .reformat_directory:
  498.     move.l        pwad_directory,a0
  499.     move.l        pwad_entries,d7
  500. .reformat_next:
  501.     imov.l        wd_offset(a0),wd_offset(a0)
  502.     imov.l        wd_size(a0),wd_size(a0)
  503.     lea        wd_len(a0),a0
  504.     subq.l        #1,d7
  505.     bne.s        .reformat_next
  506.     rts
  507.     
  508. *-------------------------------------------------------*
  509. *    Load & format all level-critical information    *
  510. *-------------------------------------------------------*
  511. load_leveldata:
  512. *-------------------------------------------------------*
  513.     move.l        all_directory,wad_mdirectory
  514.     move.l        all_entries,wad_mentries    
  515.     lea        levelmarker,a0
  516.     cmp.l        #-1,(a0)
  517.     beq.s        .use_default
  518.     bsr        place_marker
  519.     tst.l        d0
  520.     beq        err_missing
  521.     push.l        a0
  522.     move.l        a0,d7
  523.     Cconws        #ascii_levelmark
  524.     Cconws        d7
  525.     Cconws        #ascii_newline
  526.     pop.l        a0    
  527. .use_default:
  528.     bsr        init_fields
  529.     move.l        wad_mentries,d7
  530.     beq        err_fields
  531.     cmp.l        #32,d7
  532.     bmi.s        .clip_search
  533.     moveq        #32,d7
  534. .clip_search:
  535.     move.l        wad_mdirectory,a1
  536.     move.w        #field_count,fields_left
  537. .next_entry:
  538.     tst.w        fields_left
  539.     beq.s        .fields_done
  540.     lea        wd_name(a1),a0
  541.     bsr        check_fields
  542.     lea        wd_len(a1),a1
  543.     subq.l        #1,d7
  544.     bne.s        .next_entry
  545.     tst.w        fields_left
  546.     beq.s        .fields_done
  547.     bra        err_fields
  548. .fields_done:
  549.     bsr        measure_linedefs
  550.     Cconws        #ascii_parsingdone
  551.     rts
  552.  
  553. *-------------------------------------------------------*
  554. *    Calculate length of all walls for mapping    *    
  555. *-------------------------------------------------------*
  556. measure_linedefs:
  557. *-------------------------------------------------------*
  558.     move.l        Seg_Array,a0
  559.     move.l        Vertex_Array,a1
  560.     move.l        Line_Array,a2
  561.     move.w        NumSegs,d0
  562.     bra.s        .go
  563. .lp:    moveq        #0,d1
  564.     move.w        seg_from(a0),d1
  565.     moveq        #0,d2
  566.     move.w        seg_to(a0),d2
  567.     move.w        vtx_x(a1,d1.l*4),d3
  568.     move.w        vtx_y(a1,d1.l*4),d4
  569.     move.w        vtx_x(a1,d2.l*4),d5
  570.     move.w        vtx_y(a1,d2.l*4),d6
  571.     sub.w        d3,d5
  572.     sub.w        d4,d6
  573.     muls.w        d5,d5
  574.     muls.w        d6,d6
  575.     add.l        d5,d6
  576.     bsr        square_root
  577.     move.l        d7,seg_length(a0)        ; temporarily use BAM field for length
  578.     lea        seg_len(a0),a0
  579. .go:    dbra        d0,.lp
  580.     rts
  581.  
  582. *-------------------------------------------------------*
  583. *    Simple subdivisional 16.16 sqrt routine        *
  584. *-------------------------------------------------------*
  585. square_root:
  586. *-------------------------------------------------------*
  587.     tst.l        d6
  588.     bpl.s        .pos
  589.     neg.l        d6
  590. .pos:    move.l        #1<<(32-1),d7
  591.     move.l        #1<<(32-2),d5
  592. .loop:    move.l        d7,d3
  593.     mulu.l        d3,d4:d3
  594.     cmp.l        d6,d4
  595.     bgt.s        .sub
  596.     blt.s        .add
  597. .done:    rts
  598. .add:    add.l        d5,d7
  599.     lsr.l        d5
  600.     bne.s        .loop
  601.     bra.s        .done
  602. .sub:    sub.l        d5,d7
  603.     lsr.l        d5
  604.     bne.s        .loop
  605.     bra.s        .done
  606.  
  607. *-------------------------------------------------------*
  608. *    Set up all leveldata search fields        *
  609. *-------------------------------------------------------*
  610. init_fields:
  611. *-------------------------------------------------------*
  612.     lea        level_fieldlist,a0
  613.     lea        level_fields,a1
  614.     moveq        #field_count-1,d2
  615. .next:    move.l        field_ascii(a0),(a1)+
  616.     lea        field_len(a0),a0
  617.     dbra        d2,.next
  618.     move.l        #-1,(a1)
  619.     rts
  620.  
  621. *-------------------------------------------------------*
  622. *    Hunt down and load each level resource        *
  623. *-------------------------------------------------------*
  624. check_fields:
  625. *-------------------------------------------------------*
  626.     lea        level_fields,a6
  627.     lea        level_fieldlist-field_len,a5
  628. .next:    lea        field_len(a5),a5
  629.     move.l        (a6)+,d0
  630.     bmi        .check_done
  631.     beq.s        .next
  632.     move.l        d0,a2
  633.     move.l        a0,a3
  634. .cmpl:    move.b        (a2)+,d2
  635.     beq.s        .same
  636.     fixcase        d2
  637.     move.b        (a3)+,d3
  638.     fixcase        d3
  639.     cmp.b        d2,d3
  640.     beq.s        .cmpl
  641. .diff:    bra.s        .next
  642. .same:    pushall
  643.     move.l        a1,a4
  644.     move.l        d0,d7
  645.     Cconws        #ascii_reading
  646.     Cconws        d7
  647.     Cconws        #ascii_wipe
  648.     move.l        wd_size(a4),d0
  649.     addq.l        #3,d0
  650.     and.b        #-4,d0
  651.     Malloc        d0
  652.     tst.l        d0
  653.     ble        .err_memory
  654.     move.l        d0,field_ptr
  655. *-------------------------------------------------------*
  656. *    Read from IWAD or PWAD depending on flag    *
  657. *-------------------------------------------------------*
  658.     move.l        wd_offset(a4),d0
  659.     bclr        #31,d0
  660.     bne.s        .pwad
  661. .iwad:    Fseek        d0,wad_handle,#0
  662.     Fread        wad_handle,wd_size(a4),field_ptr
  663.     bra.s        .rdon
  664. .pwad:    Fseek        d0,pwad_handle,#0
  665.     Fread        pwad_handle,wd_size(a4),field_ptr
  666. *-------------------------------------------------------*
  667. .rdon:    tst.l        d0
  668.     bmi        .err_truncated        
  669.     move.l        field_module(a5),a2
  670.     move.l        wd_size(a4),d0
  671.     jsr        (a2)
  672.     Mfree        field_ptr
  673.     popall
  674.     subq.w        #1,fields_left
  675.     clr.l        -4(a6)
  676. .check_done:
  677.     rts
  678. .err_memory:
  679.     popall
  680.     bra        err_memory
  681. .err_truncated:
  682.     popall
  683.     bra        err_truncated
  684.     
  685. *-------------------------------------------------------*
  686. *    Place search-marker in WAD directory        *
  687. *-------------------------------------------------------*
  688. place_marker:
  689. *-------------------------------------------------------*
  690.     move.l        a0,wad_searchfield
  691.     move.l        all_directory,a1
  692.     move.l        all_entries,d1
  693. .search_next:
  694.     lea        wd_name(a1),a2
  695.     move.l        a0,a3
  696.     moveq        #8-1,d4
  697. .search_look:
  698.     move.b        (a3)+,d2
  699.     beq.s        .search_stop
  700.     fixcase        d2
  701.     move.b        (a2)+,d3
  702.     fixcase        d3
  703.     cmp.b        d2,d3    
  704.     bne.s        .search_diff
  705.     dbra        d4,.search_look
  706.     bra.s        .search_over
  707. .search_diff:    
  708.     lea        wd_len(a1),a1
  709.     subq.l        #1,d1
  710.     bne.s        .search_next
  711. .search_fail:
  712.     moveq        #0,d0
  713.     bra.s        .search_exit
  714. .search_stop:
  715.     tst.b        (a2)+
  716.     bne.s        .search_diff
  717. .search_over:
  718.     move.l        a1,wad_mdirectory
  719.     move.l        d1,wad_mentries
  720.     moveq        #1,d0
  721. .search_exit:
  722.     rts
  723.  
  724. *-------------------------------------------------------*
  725. *    Find & load any resource from WAD        *
  726. *-------------------------------------------------------*
  727. load_resource:
  728. *-------------------------------------------------------*
  729.     move.l        a0,wad_searchfield
  730.     move.l        all_directory,a1
  731.     move.l        all_entries,d1
  732. .search_next:
  733.     lea        wd_name(a1),a2
  734.     move.l        a0,a3
  735.     moveq        #8-1,d4
  736. .search_look:
  737.     move.b        (a3)+,d2
  738.     beq.s        .search_stop
  739.     fixcase        d2
  740.     move.b        (a2)+,d3
  741.     fixcase        d3
  742.     cmp.b        d2,d3    
  743.     bne.s        .search_diff
  744.     dbra        d4,.search_look
  745.     bra.s        .search_over
  746. .search_diff:    
  747.     lea        wd_len(a1),a1
  748.     subq.l        #1,d1
  749.     bne.s        .search_next
  750. .search_fail:
  751.     moveq        #0,d0
  752.     bra        .search_exit
  753. .search_stop:
  754.     tst.b        (a2)+
  755.     bne.s        .search_diff
  756. .search_over:
  757.     move.l        a1,wad_mdirectory
  758.     move.l        wd_size(a1),d6
  759.     Malloc        d6
  760.     tst.l        d0
  761.     ble.s        .search_fail
  762.     move.l        d0,a6
  763.     move.l        a1,a4
  764.     pushall
  765. *-------------------------------------------------------*
  766. *    Read from IWAD or PWAD depending on flag    *
  767. *-------------------------------------------------------*
  768.     move.l        wd_offset(a4),d0
  769.     bclr        #31,d0
  770.     bne.s        .pwad
  771. .iwad:    Fseek        d0,wad_handle,#0
  772.     Fread        wad_handle,wd_size(a4),a6
  773.     bra.s        .rdon
  774. .pwad:    Fseek        d0,pwad_handle,#0
  775.     Fread        pwad_handle,wd_size(a4),a6
  776. *-------------------------------------------------------*
  777. .rdon    popall
  778.     moveq        #1,d0
  779. .search_exit:
  780.     rts
  781.  
  782. *-------------------------------------------------------*
  783. *    Direct-access version of load_resource        *
  784. *-------------------------------------------------------*
  785. read_resource:
  786. *-------------------------------------------------------*
  787.     pushall
  788.     move.l        a0,a4
  789.     move.l        a1,a6
  790.     move.l        wd_size(a4),d6
  791. *-------------------------------------------------------*
  792. *    Read from IWAD or PWAD depending on flag    *
  793. *-------------------------------------------------------*
  794.     move.l        wd_offset(a4),d0
  795.     bclr        #31,d0
  796.     bne.s        .pwad
  797. .iwad:    Fseek        d0,wad_handle,#0
  798.     Fread        wad_handle,wd_size(a4),a6
  799.     bra.s        .rdon
  800. .pwad:    Fseek        d0,pwad_handle,#0
  801.     Fread        pwad_handle,wd_size(a4),a6
  802. *-------------------------------------------------------*
  803. .rdon:    popall
  804.     rts
  805.  
  806. *-------------------------------------------------------*
  807. *    Open IWAD file for work                *
  808. *-------------------------------------------------------*
  809. open_wad:
  810. *-------------------------------------------------------*
  811.     movem.l        d1-a6,-(sp)
  812.     tst.w        wad_handle
  813.     bne.s        .open
  814.     Fopen        #iwad_path,#0
  815.     tst.w        d0
  816.     bmi.s        .open
  817.     move.w        d0,wad_handle
  818. .open:    movem.l        (sp)+,d1-a6
  819.     rts
  820.  
  821. *-------------------------------------------------------*
  822. *    Open PWAD file for work                *
  823. *-------------------------------------------------------*
  824. open_pwad:
  825. *-------------------------------------------------------*
  826.     movem.l        d1-a6,-(sp)
  827.     tst.w        pwad_handle
  828.     bne.s        .open
  829.     Fopen        #pwad_path,#0
  830.     tst.w        d0
  831.     bmi.s        .open
  832.     move.w        d0,pwad_handle
  833. .open:    movem.l        (sp)+,d1-a6
  834.     rts
  835.     
  836. *-------------------------------------------------------*
  837. *    Close IWAD if already open            *
  838. *-------------------------------------------------------*
  839. close_wad:
  840. *-------------------------------------------------------*
  841.     movem.l        d1-a6,-(sp)
  842.     tst.w        wad_handle
  843.     beq.s        .ic
  844.     Fclose        wad_handle
  845.     clr.w        wad_handle
  846. .ic    movem.l        (sp)+,d1-a6
  847.     rts
  848.  
  849. *-------------------------------------------------------*
  850. *    Close PWAD if already open            *
  851. *-------------------------------------------------------*
  852. close_pwad:
  853. *-------------------------------------------------------*
  854.     movem.l        d1-a6,-(sp)
  855.     tst.w        pwad_handle
  856.     beq.s        .pc
  857.     Fclose        pwad_handle
  858.     clr.w        pwad_handle
  859. .pc:    movem.l        (sp)+,d1-a6
  860.     rts
  861.  
  862. *-------------------------------------------------------*
  863. *    Print decimal number to TOS console        *
  864. *-------------------------------------------------------*
  865. output_decimal:
  866. *-------------------------------------------------------*
  867.     lea        stringspace,a0
  868.     moveq        #'0',d2
  869.     moveq        #10,d3
  870. .build:    moveq        #0,d5
  871.     divu.l        d3,d5:d0
  872.     add.w        d2,d5
  873.     move.b        d5,-(a0)
  874.     subq.l        #1,d1
  875.     bgt.s        .build
  876.     tst.l        d0
  877.     bne.s        .build
  878.     Cconws        a0
  879.     rts
  880.  
  881. *-------------------------------------------------------*
  882. *    Load & reformat 'things'            *
  883. *-------------------------------------------------------*
  884. things_module:
  885. *-------------------------------------------------------*
  886.     divu.l        #Thing_len,d0
  887.     move.w        d0,NumThings
  888.     move.w        d0,d7
  889.     mulu.w        #Thing_len,d0
  890.     Malloc        d0
  891.     beq        error_alloc
  892.     move.l        d0,Thing_Array
  893.     move.l        d0,a1
  894.     move.l        field_ptr,a0
  895.     bra.s        .next_thing    
  896. .thing_loop:
  897.     imov.w        Thing_type(a0),d1
  898.     cmp.w        #1,d1
  899.     bne.s        .no_player
  900.     bsr        .setup_player
  901. .no_player:
  902.     moveq        #(Thing_len/2)-1,d6
  903. .ilp:    imov.w        (a0)+,(a1)+
  904.     dbra        d6,.ilp
  905. .next_thing:
  906.     dbra        d7,.thing_loop
  907.     rts
  908.  
  909. .setup_player:
  910.     imov.w        Thing_x(a0),px
  911.     imov.w        Thing_y(a0),py
  912.     imov.w        Thing_angle(a0),d1
  913.     swap        d1
  914.     clr.w        d1
  915.     divu.w        #360,d1
  916.     move.w        d1,pangle
  917.     rts
  918.  
  919. *-------------------------------------------------------*
  920. *    Load & reformat 'linedefs'            *
  921. *-------------------------------------------------------*
  922. linedefs_module:
  923.     divu.l        #Line_len,d0
  924.     move.w        d0,NumLines
  925.     move.w        d0,d7
  926.     mulu.w        #Line_len,d0
  927.     Malloc        d0
  928.     beq        error_alloc
  929.     move.l        d0,Line_Array
  930.     move.l        d0,a1
  931.     move.l        field_ptr,a0
  932.     bra.s        .next_line
  933. .line_loop:
  934.     moveq        #(Line_len/2)-1,d6
  935. .ilp:    imov.w        (a0)+,(a1)+
  936.     dbra        d6,.ilp
  937. .next_line:
  938.     dbra        d7,.line_loop
  939.     rts
  940.     
  941. *-------------------------------------------------------*
  942. *    Load & reformat 'sidedefs'            *
  943. *-------------------------------------------------------*
  944. sidedefs_module:
  945. *-------------------------------------------------------*
  946.     divu.l        #Side_len,d0
  947.     move.w        d0,NumSides
  948.     move.w        d0,d7
  949.     mulu.w        #Side_len,d0
  950.     Malloc        d0
  951.     beq        error_alloc
  952.     move.l        d0,Side_Array
  953.     move.l        d0,a1
  954.     move.l        field_ptr,a0
  955.     bra.s        .next_side
  956. .side_loop:
  957.     imov.w        (a0)+,(a1)+
  958.     imov.w        (a0)+,(a1)+
  959.     move.l        (a0)+,(a1)+
  960.     move.l        (a0)+,(a1)+
  961.     move.l        (a0)+,(a1)+
  962.     move.l        (a0)+,(a1)+
  963.     move.l        (a0)+,(a1)+
  964.     move.l        (a0)+,(a1)+
  965.     imov.w        (a0)+,(a1)+
  966. .next_side:
  967.     dbra        d7,.side_loop
  968.     rts
  969.  
  970. *-------------------------------------------------------*
  971. *    Load & reformat 'vertexes'            *
  972. *-------------------------------------------------------*
  973. vertexes_module:
  974. *-------------------------------------------------------*
  975.     divu.l        #Vertex_len,d0
  976.     move.w        d0,NumVertices
  977.     move.w        d0,d7
  978.     mulu.w        #Vertex_len,d0
  979.     Malloc        d0
  980.     beq        error_alloc
  981.     move.l        d0,Vertex_Array
  982.     move.l        d0,a1
  983.     move.l        field_ptr,a0
  984.     bra.s        .next_vertex
  985. .vertex_loop:
  986.     moveq        #(Vertex_len/2)-1,d6
  987. .ilp:    imov.w        (a0)+,(a1)+
  988.     dbra        d6,.ilp
  989. .next_vertex:
  990.     dbra        d7,.vertex_loop
  991.     rts
  992.  
  993. *-------------------------------------------------------*
  994. *    Load & reformat 'segs'                *
  995. *-------------------------------------------------------*
  996. segs_module:
  997. *-------------------------------------------------------*
  998.     divu.l        #Seg_len,d0
  999.     move.w        d0,NumSegs
  1000.     move.w        d0,d7
  1001.     mulu.w        #seg_len,d0
  1002.     Malloc        d0
  1003.     beq        error_alloc
  1004.     move.l        d0,Seg_Array
  1005.     move.l        d0,a1
  1006.     move.l        field_ptr,a0
  1007.     bra.s        .next_seg
  1008. .seg_loop:
  1009.     moveq        #(Seg_len/2)-1,d6
  1010. .ilp:    imov.w        (a0)+,(a1)+
  1011.     dbra        d6,.ilp
  1012.     addq.l        #4,a1
  1013. .next_seg:
  1014.     dbra        d7,.seg_loop
  1015.     rts
  1016.  
  1017. *-------------------------------------------------------*
  1018. *    Load & reformat 'ssectors'            *
  1019. *-------------------------------------------------------*
  1020. ssectors_module:
  1021. *-------------------------------------------------------*
  1022.     divu.l        #Ssect_len,d0
  1023.     move.w        d0,NumSSectors
  1024.     move.w        d0,d7
  1025.     mulu.w        #Ssect_len,d0
  1026.     Malloc        d0
  1027.     beq        error_alloc
  1028.     move.l        d0,SSector_Array
  1029.     move.l        d0,a1
  1030.     move.l        field_ptr,a0
  1031.     bra.s        .next_ssector
  1032. .ssector_loop:
  1033.     moveq        #(Ssect_len/2)-1,d6
  1034. .ilp:    imov.w        (a0)+,(a1)+
  1035.     dbra        d6,.ilp
  1036. .next_ssector:
  1037.     dbra        d7,.ssector_loop
  1038.     rts
  1039.  
  1040. *-------------------------------------------------------*
  1041. *    Load & reformat 'nodes'                *
  1042. *-------------------------------------------------------*
  1043. nodes_module:
  1044. *-------------------------------------------------------*
  1045.     divu.l        #Node_len,d0
  1046.     move.w        d0,NumNodes
  1047.     move.w        d0,d7
  1048.     mulu.w        #Node_len,d0
  1049.     Malloc        d0
  1050.     beq        error_alloc
  1051.     move.l        d0,Node_Array
  1052.     move.l        d0,a1
  1053.     move.l        field_ptr,a0
  1054.     bra.s        .next_node
  1055. .node_loop:
  1056.     moveq        #(Node_len/2)-1,d6
  1057. .ilp:    imov.w        (a0)+,(a1)+
  1058.     dbra        d6,.ilp
  1059. .next_node:
  1060.     dbra        d7,.node_loop
  1061. .err:    rts
  1062.  
  1063. *-------------------------------------------------------*
  1064. *    Load & reformat 'sectors'            *
  1065. *-------------------------------------------------------*
  1066. sectors_module:
  1067. *-------------------------------------------------------*
  1068.     divu.l        #Sector_len,d0
  1069.     move.w        d0,NumSectors
  1070.     move.w        d0,d7
  1071.     mulu.w        #Sector_len,d0
  1072.     Malloc        d0
  1073.     beq        error_alloc
  1074.     move.l        d0,Sector_Array
  1075.     move.l        d0,a1
  1076.     move.l        field_ptr,a0
  1077.     bra.s        .next_sector
  1078. .sector_loop:
  1079.     imov.w        (a0)+,(a1)+
  1080.     imov.w        (a0)+,(a1)+
  1081.     move.l        (a0)+,(a1)+
  1082.     move.l        (a0)+,(a1)+
  1083.     move.l        (a0)+,(a1)+
  1084.     move.l        (a0)+,(a1)+
  1085.     imov.w        (a0)+,(a1)+
  1086.     imov.w        (a0)+,(a1)+
  1087.     imov.w        (a0)+,(a1)+
  1088. .next_sector:
  1089.     dbra        d7,.sector_loop
  1090.     rts
  1091.  
  1092. *-------------------------------------------------------*
  1093. *    Load & reformat 'reject'            *
  1094. *-------------------------------------------------------*
  1095. reject_module:
  1096. *-------------------------------------------------------*
  1097.     rts
  1098.  
  1099. *-------------------------------------------------------*
  1100. *    Load & reformat 'blockmap'            *
  1101. *-------------------------------------------------------*
  1102. blockmap_module:
  1103. *-------------------------------------------------------*
  1104.     rts
  1105.  
  1106. error_alloc:
  1107.     Cconws        #ascii_err_pnodes
  1108.     bra        err_closewad
  1109.  
  1110. *-------------------------------------------------------*
  1111. *    Modified strcmp for texture name-searching    *
  1112. *-------------------------------------------------------*
  1113. strcmp_8:
  1114. *-------------------------------------------------------*
  1115.     push.l        a0
  1116.     push.l        a1
  1117.     moveq        #8-1,d2
  1118.     moveq        #0,d0
  1119. .loop:    swap        d2
  1120.     move.b        (a0)+,d3
  1121.     beq.s        .term
  1122.     fixcase        d3
  1123.     move.b        (a1)+,d2
  1124.     fixcase        d2
  1125.     cmp.b        d2,d3
  1126.     bne.s        .diff
  1127.     swap        d2
  1128.     dbra        d2,.loop
  1129.     bra.s        .same
  1130. .term:    tst.b        (a1)+
  1131.     bne.s        .diff
  1132. .same:    moveq        #1,d0
  1133. .diff:    pop.l        a1
  1134.     pop.l        a0
  1135.     rts
  1136.  
  1137. *-------------------------------------------------------*
  1138. *    Modified strcmp for texture name-searching    *
  1139. *-------------------------------------------------------*
  1140. strcmp_8_wild:
  1141. *-------------------------------------------------------*
  1142.     push.l        a0
  1143.     push.l        a1
  1144.     moveq        #8-1,d2
  1145.     moveq        #0,d0
  1146. .loop:    swap        d2
  1147.     move.b        (a0)+,d3
  1148.     beq.s        .term
  1149.     cmp.b        #'?',d3
  1150.     beq.s        .same
  1151.     fixcase        d3
  1152.     move.b        (a1)+,d2
  1153.     cmp.b        #'?',d2
  1154.     beq.s        .same
  1155.     fixcase        d2
  1156.     cmp.b        d2,d3
  1157.     bne.s        .diff
  1158.     swap        d2
  1159.     dbra        d2,.loop
  1160.     bra.s        .same
  1161. .term:    tst.b        (a1)+
  1162.     bne.s        .diff
  1163. .same:    moveq        #1,d0
  1164. .diff:    pop.l        a1
  1165.     pop.l        a0
  1166.     rts
  1167.  
  1168. *-------------------------------------------------------*
  1169. *    Miscellaneous error trapping units        *
  1170. *-------------------------------------------------------*
  1171. *    Can be replaced with generalised error handler    *
  1172. *    at some later stage to reduce complexity.    *
  1173. *-------------------------------------------------------*
  1174.  
  1175. *-------------------------------------------------------*
  1176. err_fields:
  1177. *-------------------------------------------------------*
  1178.     Cconws        #ascii_newline
  1179.     lea        level_fields,a6
  1180.     move.w        #field_count-1,d6
  1181. .loop:    move.l        (a6)+,d7
  1182.     beq.s        .next
  1183.     move.l        d7,a0
  1184.     bsr        entry_missing_e
  1185. .next:    dbra        d6,.loop
  1186.     bra        err_closewad
  1187.  
  1188. *-------------------------------------------------------*
  1189. err_missing:
  1190. *-------------------------------------------------------*
  1191.     Cconws        #ascii_newline
  1192.     move.l        wad_searchfield,a0
  1193.     bsr        entry_missing_e
  1194.     bra        err_closewad
  1195.  
  1196. *-------------------------------------------------------*
  1197. err_truncated:
  1198. *-------------------------------------------------------*
  1199.     Cconws        #ascii_newline
  1200.     move.l        wad_searchfield,a0
  1201.     bsr        entry_truncated
  1202.     bra        err_closewad
  1203.  
  1204. *-------------------------------------------------------*
  1205. err_memory:
  1206. *-------------------------------------------------------*
  1207.     Cconws        #ascii_err_memory
  1208.     bra        err_closewad
  1209.  
  1210. *-------------------------------------------------------*
  1211. err_badwad:
  1212. *-------------------------------------------------------*
  1213.     Cconws        #ascii_err_badwad
  1214.     bra        err_closewad
  1215.  
  1216. *-------------------------------------------------------*
  1217. err_badpwad:
  1218. *-------------------------------------------------------*
  1219.     Cconws        #ascii_err_badpwad
  1220.     bra        err_closewad
  1221.  
  1222. *-------------------------------------------------------*
  1223. err_openwad:
  1224. *-------------------------------------------------------*
  1225.     Cconws        #ascii_err_openwad
  1226.     bra        err_closewad
  1227.  
  1228. *-------------------------------------------------------*
  1229. err_closewad:
  1230. *-------------------------------------------------------*
  1231.     bsr        close_wad
  1232.     bsr        close_pwad
  1233.     Crawcin
  1234.     jmp        safe_quit
  1235.  
  1236. *-------------------------------------------------------*
  1237. entry_missing_w:
  1238. *-------------------------------------------------------*
  1239.     pushall
  1240.     lea        string_space,a1
  1241.     move.l        a1,a6
  1242.     move.l        (a0)+,(a1)+
  1243.     move.l        (a0)+,(a1)+
  1244.     clr.b        (a1)
  1245.     Cconws        #ascii_err_missing1w
  1246.     Cconws        a6
  1247.     Cconws        #ascii_err_missing2w
  1248.     popall
  1249.     rts
  1250.  
  1251. *-------------------------------------------------------*
  1252. entry_missing_e:
  1253. *-------------------------------------------------------*
  1254.     pushall
  1255.     lea        string_space,a1
  1256.     move.l        a1,a6
  1257.     move.l        (a0)+,(a1)+
  1258.     move.l        (a0)+,(a1)+
  1259.     clr.b        (a1)
  1260.     Cconws        #ascii_err_missing1e
  1261.     Cconws        a6
  1262.     Cconws        #ascii_err_missing2e
  1263.     popall
  1264.     rts
  1265.  
  1266. *-------------------------------------------------------*
  1267. entry_truncated:
  1268. *-------------------------------------------------------*
  1269.     pushall
  1270.     lea        string_space,a1
  1271.     move.l        a1,a6
  1272.     move.l        (a0)+,(a1)+
  1273.     move.l        (a0)+,(a1)+
  1274.     clr.b        (a1)
  1275.     Cconws        #ascii_err_trunc1
  1276.     Cconws        a6
  1277.     Cconws        #ascii_err_trunc2
  1278.     popall
  1279.     rts
  1280.  
  1281. check_limits:
  1282.     move.w        num_required,d1
  1283.     cmp.w        num_reserved,d1
  1284.     bgt.s        .err
  1285.     rts
  1286. .err:    Cconws        #ascii_limits1
  1287.     moveq        #0,d0
  1288.     move.w        num_reserved,d0
  1289.     moveq        #1,d1
  1290.     bsr        output_decimal
  1291.     Cconws        #ascii_limits2
  1292.     moveq        #0,d0
  1293.     move.w        num_required,d0
  1294.     moveq        #1,d1
  1295.     bsr        output_decimal
  1296.     bra        err_closewad
  1297.  
  1298. *-------------------------------------------------------*
  1299.             datlong
  1300. *-------------------------------------------------------*
  1301.  
  1302. level_fieldlist:    dc.l    ascii_things,things_module    ; list of leveldata resources
  1303.             dc.l    ascii_nodes,nodes_module
  1304.             dc.l    ascii_sectors,sectors_module
  1305.             dc.l    ascii_ssectors,ssectors_module
  1306.             dc.l    ascii_segs,segs_module
  1307.             dc.l    ascii_linedefs,linedefs_module
  1308.             dc.l    ascii_sidedefs,sidedefs_module
  1309.             dc.l    ascii_vertexes,vertexes_module
  1310.             dc.l    ascii_reject,reject_module
  1311.             dc.l    ascii_blockmap,blockmap_module
  1312.             dc.l    terminator
  1313.  
  1314. wad_signature:        ds.l    1                ; IWAD signature
  1315.             dc.b    0
  1316. pwad_signature:        ds.l    1                ; PWAD signature
  1317.             dc.b    0
  1318.  
  1319. *-------------------------------------------------------*
  1320. *    General ASCII messages follow...        *
  1321. *-------------------------------------------------------*
  1322.  
  1323. ascii_mask_exmx:    dc.b    'e?m?',0
  1324. ascii_mask_mapxx:    dc.b    'map??',0
  1325.  
  1326. ascii_texture1:        dc.b    'texture1',0        ; WAD search details
  1327. ascii_texture2:        dc.b    'texture2',0
  1328. ascii_pnames:        dc.b    'pnames',0
  1329. ascii_sky:        dc.b    'f_sky1',0
  1330. ascii_fstart:        dc.b    'f_start',0
  1331. ascii_fend:        dc.b    'f_end',0
  1332. ascii_pstart:        dc.b    'p_start',0
  1333. ascii_pend:        dc.b    'p_end',0
  1334. ascii_qalpha:        dc.b    'sky1',0
  1335.  
  1336. ascii_sky1:        dc.b    'sky1',0
  1337. ascii_sky2:        dc.b    'sky2',0
  1338. ascii_sky3:        dc.b    'sky3',0
  1339. ascii_sky4:        dc.b    'sky4',0
  1340.  
  1341. ascii_loadflats:    dc.b    13,10
  1342.             dc.b    ' Preloading floor & ceiling textures...',0
  1343. ascii_loadwalls:    dc.b    13,10
  1344.             dc.b    ' Preloading wall textures...',0
  1345. ascii_readpnames:    dc.b    13,10
  1346.             dc.b    ' Reading [pnames] directory...',0
  1347. ascii_readtex1:        dc.b    13,10
  1348.             dc.b    ' Reading [texture1] directory...',0
  1349. ascii_readtex2:        dc.b    13,10
  1350.             dc.b    ' Reading [texture2] directory...',0
  1351. ascii_hashtex:        dc.b    13,10
  1352.             dc.b    ' Generating hashtable...',0
  1353. ascii_replacetex:    dc.b    13,10
  1354.             dc.b    ' Replacing textures...',0
  1355. ascii_replaceflat:    dc.b    13,10
  1356.             dc.b    ' Replacing flats...',0
  1357. ascii_fixsky:        dc.b    13,10
  1358.             dc.b    ' Validating sky sidedefs...',0
  1359. ascii_patchalpha:    dc.b    13,10
  1360.             dc.b    ' Patching quick-alpha textures...',0
  1361. ascii_locatepatch:    dc.b    13,10
  1362.             dc.b    ' Organising patches...',0
  1363. ascii_replacedone:    dc.b    13,10
  1364.             dc.b    13,10
  1365.             dc.b    ' Finished processing textures.',0
  1366. ascii_integrate:    dc.b    13,10
  1367.             dc.b    ' Integrating PWAD...'
  1368.             dc.b    13,10,13,10,0
  1369.  
  1370. ascii_warp_switch:    dc.b    'w',0
  1371. ascii_iwad_switch:    dc.b    'i',0
  1372. ascii_pwad_switch:    dc.b    'p',0
  1373.     
  1374. ascii_signal:        dc.b    13,10,'signal',0
  1375. ascii_newline:        dc.b    13,10,0
  1376. ascii_startup:        dc.b    27,'E',27,'f',13,10
  1377.             dc.b    ' Doom Environment Simulator v2.14alpha.',13,10,13,10
  1378.             dc.b    ' DSP Doom engine by Doug Little.',13,10,0
  1379.  
  1380. ascii_format1:        dc.b    13,10
  1381.             dc.b    ' IWAD check:    ',0
  1382. ascii_format2:        dc.b    13,10
  1383.             dc.b    ' PWAD check:    ',0
  1384.  
  1385. ascii_levelmark:    dc.b    ' Warp to:    ',0
  1386. ascii_reading:        dc.b    13
  1387.             dc.b    ' Reading:    ',0
  1388. ascii_wipe:        dc.b    '        ',0
  1389.  
  1390. ascii_entries:        dc.b    13,10
  1391.             dc.b    ' Directories:    ',0
  1392.  
  1393. ascii_limits1:        dc.b    13,10
  1394.             dc.b    13,10
  1395.             dc.b    ' Too many elements!',13,10
  1396.             dc.b    ' Reserved: ',0
  1397. ascii_limits2:        dc.b    13,10,' Required: ',0
  1398.  
  1399. ascii_entriesdone:    dc.b    13,10,0
  1400.  
  1401. ascii_parsingdone:    dc.b    13,10
  1402.             dc.b    13,10
  1403.             dc.b    ' Finished processing leveldata.',13,10,0 
  1404.  
  1405. ascii_err_missing1e:    dc.b    13,10
  1406.             dc.b    ' Missing:    ',0
  1407. ascii_err_missing2e:    dc.b    ' -> [error]',0
  1408.  
  1409. ascii_err_missing1w:    dc.b    13,10
  1410.             dc.b    ' Missing:    ',0
  1411. ascii_err_missing2w:    dc.b    ' -> [warning]',0
  1412.  
  1413. ascii_err_trunc1:    dc.b    13,10
  1414.             dc.b    ' Truncated:    ',0
  1415. ascii_err_trunc2:    dc.b    ' -> [error]',0
  1416.  
  1417. ascii_err_notex:    dc.b    13,10
  1418.             dc.b    ' WAD contains no [textures] -> [warning]',0
  1419. ascii_err_noflats:    dc.b    13,10
  1420.             dc.b    ' WAD contains no [flats] -> [warning]',0
  1421. ascii_err_nopatches:    dc.b    13,10
  1422.             dc.b    ' WAD contains no [patches] -> [warning]',0
  1423. ascii_err_pnodes:    dc.b    13,10
  1424.             dc.b    ' Could not allocate space for [nodes] -> [error]',0
  1425. ascii_err_memory:    dc.b    13,10
  1426.             dc.b    ' Could not allocate space for [arrays] -> [error]',0
  1427. ascii_err_openwad:    dc.b    13,10
  1428.             dc.b    ' Could not find & open WAD file -> [error]',0
  1429. ascii_err_badwad:    dc.b    13,10
  1430.             dc.b    ' The specified IWAD is not compatible -> [error]',0
  1431. ascii_err_badpwad:    dc.b    13,10
  1432.             dc.b    ' The specified PWAD is not compatible -> [error]',0
  1433.  
  1434. *-------------------------------------------------------*
  1435. *    Leveldata search details            *
  1436. *-------------------------------------------------------*
  1437.  
  1438. ascii_things:        dc.b    'things',0
  1439. ascii_linedefs:        dc.b    'linedefs',0
  1440. ascii_sidedefs:        dc.b    'sidedefs',0
  1441. ascii_vertexes:        dc.b    'vertexes',0
  1442. ascii_segs:        dc.b    'segs',0
  1443. ascii_ssectors:        dc.b    'ssectors',0
  1444. ascii_nodes:        dc.b    'nodes',0
  1445. ascii_sectors:        dc.b    'sectors',0
  1446. ascii_reject:        dc.b    'reject',0
  1447. ascii_blockmap:        dc.b    'blockmap',0
  1448.  
  1449. ascii_colormap:        dc.b    'colormap',0
  1450. ascii_playpal:        dc.b    'playpal',0
  1451.  
  1452. *-------------------------------------------------------*
  1453.             bsslong
  1454. *-------------------------------------------------------*
  1455.  
  1456. wad_diroffset:        ds.l    1
  1457. pwad_diroffset:        ds.l    1
  1458.  
  1459. wad_directory:        ds.l    1
  1460. wad_entries:        ds.l    1
  1461.  
  1462. pwad_directory:        ds.l    1
  1463. pwad_entries:        ds.l    1
  1464.  
  1465. all_directory:        ds.l    1
  1466. all_entries:        ds.l    1
  1467.  
  1468. *-------------------------------------------------------*
  1469.  
  1470. wad_mentries:        ds.l    1        ; wad search & retrieve variables
  1471. wad_mdirectory:        ds.l    1
  1472. wad_searchfield:    ds.l    1
  1473.  
  1474.  
  1475. field_ptr:        ds.l    1
  1476.  
  1477. Seg_Array        ds.l    1        ; leveldata array pointers
  1478. Side_Array        ds.l    1
  1479. Line_Array        ds.l    1
  1480. Node_Array        ds.l    1
  1481. PNode_Array        ds.l    1
  1482. Sector_Array        ds.l    1
  1483. Vertex_Array        ds.l    1
  1484. SSector_Array        ds.l    1
  1485. Thing_Array        ds.l    1
  1486.  
  1487. colormap_ptr:        ds.l    1        ; palette & colourmap pointers
  1488. playpal_ptr:        ds.l    1
  1489.  
  1490. level_fields:        ds.l    field_count+1    ; space for level search information
  1491.  
  1492. switch_space:        ds.b    8+1
  1493. cli_space:        ds.b    255+1
  1494.  
  1495. wad_header:        ds.b    wh_len        ; space for IWAD header
  1496. wad_handle:        ds.w    1        ; IWAD handle
  1497.  
  1498. pwad_header:        ds.b    wh_len        ; space for PWAD header
  1499. pwad_handle:        ds.w    1        ; PWAD handle
  1500.  
  1501. fields_left:        ds.w    1        ; leveldata field count
  1502.  
  1503. num_reserved:        ds.w    1
  1504. num_required:        ds.w    1
  1505.  
  1506. NumThings:        ds.w    1        ; various array sizes
  1507. NumSegs:        ds.w    1
  1508. NumLines:        ds.w    1
  1509. NumSides:        ds.w    1
  1510. NumVertices:        ds.w    1
  1511. NumSSectors:        ds.w    1
  1512. NumNodes:        ds.w    1
  1513. NumSectors:        ds.w    1
  1514.  
  1515. *-------------------------------------------------------*
  1516.             txtlong
  1517. *-------------------------------------------------------*
  1518.  
  1519.